package org.example;

/**
 * Hello world!
 */
public class App2 {


    static void move(String x, String y) {
        System.out.println(String.format("%s->%s", x, y));
    }

    static void Hanoi(int n, String a, String b, String c) {
//        System.out.println(n);
        if (n == 1) {
//            move(a, c);
//            System.out.println("移动成功");
        } else {

            Hanoi(n - 1, a, c, b);//将A座上的n-1个盘子借助C座移向B座
//            move(a, c);//将A座上最后一个盘子移向C座
            Hanoi(n - 1, b, a, c);//将B座上的n-1个盘子借助A座移向C座
        }
    }

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        Hanoi(40, "a", "b", "c");
        System.out.println("执行时间：" + String.format("%s", System.currentTimeMillis() - time));
    }
}

